//
//  BaseModel.m
//  UI22_项目框架
//
//  Created by dllo on 15/7/3.
//  Copyright (c) 2015年 蓝天. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel

- (void)dealloc
{
    [super dealloc];
}

- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

#pragma mark - 便利构造 
+ (instancetype)baseModelWithDic:(NSDictionary *)dic
{
    id objc = [[[[self class] alloc] initWithDic:dic] autorelease];
    return objc;
}
#pragma mark - 转化方法
+ (NSMutableArray *)arrayWithModelByArray:(NSArray *)array
{
    // 创建一个可变数组 保存model 并返回结果
    NSMutableArray *arr = [NSMutableArray array];
    // 遍历 参数 数组
    for (NSDictionary *dic in array) {
        @autoreleasepool {
            
            // 创建对象
            id model = [[self class] baseModelWithDic:dic];
            // 添加数组
            [arr addObject:model];
        }
    }
    return arr;
}


- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

- (id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}
@end
